package com.imooc.action;

import com.imooc.po.User;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class LoginAction extends ActionSupport implements ModelDriven<User> {
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -4508071990715409897L;
	
	

	public String login(){
		if (user.getUsername()==null||"".equals(user.getUsername())) {
			this.addFieldError("username", "�û�������Ϊ�գ�");
			return INPUT;
		}
		System.out.println(user.getUsername());
		System.out.println(user.getBookList().get(0));
		return SUCCESS;
	}
	
	
	
	
	// ʹ�� 
//	private User user;
//	
//	public User getUser() {
//		return user;
//	}
//
//	public void setUser(User user) {
//		this.user = user;
//	}

	private User user=new User();
	
	public User getModel() {
		return user;
	}
	
	
//	private String username;
//	private String password;
//	
//	public String getUsername() {
//		return username;
//	}
//	public void setUsername(String username) {
//		this.username = username;
//	}
//	public String getPassword() {
//		return password;
//	}
//	public void setPassword(String password) {
//		this.password = password;
//	}
	
	@Override
	public void validate() {
		if (user.getUsername()==null||"".equals(user.getUsername())) {
			this.addFieldError("username", "�û�������Ϊ�գ�");
		}
	}
	
	
}
